//
//  ForbiddenCell.m
//  YouinRTCDemo
//
//  Created by 潘欣 on 2023/4/16.
//

#import "ForbiddenCell.h"

@interface ForbiddenCell ()
@property (nonatomic,strong)UIImageView *img;
@property (nonatomic,strong)UILabel *name;

@end

@implementation ForbiddenCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if(self){
        [self.img mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self).offset(10);
            make.left.mas_equalTo(self).offset(10);
            make.width.and.height.offset(40);
        }];
        
        [self.name mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.img.mas_right).offset(7);
            make.centerY.mas_equalTo(self.img);
        }];
        
        [self.removeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.mas_equalTo(self).offset(-10);
            make.centerY.mas_equalTo(self);
//            make.width.offset(1)
        }];
        
    }
    return self;
}

- (void)setModel:(RTCKickOutModel *)model
{
    _model = model;
    [self.img sd_setImageWithURL:[NSURL URLWithString:model.userImage]];
    self.name.text = model.nickname;
    
    
}
- (UIImageView *)img
{
    if(!_img){
        _img = [[UIImageView alloc] init];
        _img.backgroundColor = [UIColor redColor];
        _img.layer.cornerRadius = 20;
        _img.clipsToBounds = YES;
        [self addSubview:_img];
    }
    return _img;
}

- (UILabel *)name
{
    if (!_name) {
        _name = [[UILabel alloc] init];
        _name.text = @"欧式简约客厅座椅";
        _name.textColor = [UIColor blackColor];
        _name.font = [UIFont systemFontOfSize:13];
        [self addSubview:_name];
    }
    return _name;
}
- (UIButton *)removeBtn
{
    if(!_removeBtn){
        _removeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_removeBtn setTitle:@"移除" forState:UIControlStateNormal];
        _removeBtn.titleLabel.font = [UIFont systemFontOfSize:15];
        [_removeBtn setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
        [self.contentView addSubview:_removeBtn];
    }
    return _removeBtn;
}
@end
